home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) Mar, 1986 UMMC. All rights reserved
-
- Filename: mkmxa.c
-
- Abstract: This module contains the code to construct the matrices used to transform between
- The AP image coordinates and the patient/table coordinates
-
- Environment: UM/CLIP
-
- Revision History:
- Rev # Date Auth Reason
- ----- --------- ----- ----------------------------------
- 0.0 17-mar-86 js original implementation
- 0.1 28-apr-86 js converted to double precision
-
- -----------------------------------------------------------------------------------------
- NAME:
-
- mkmxa - make coordinate transform matrices (AP)
-
- SYNOPSIS:
-
- ERRCODE mkmxa (alpha, beta, a2p, p2a)
-
- INT alpha; angle alpha for the AP C-arm
- INT beta; angle beta for the AP C-arm
- DOUBLE a2p[9]; array for 'AP to patient' transform matrix
- DOUBLE p2a[9]; array for 'patient to AP' transform matrix
-
- MODIFIED ARGUMENTS:
-
- a2p and p2a will contain the transform matrices corresponding to angles alpha and beta
-
- FUNCTION:
-
- Matrix methods are used in order to implement transformations between the coordinate
- systems subtended by the AP image plane and the patient. It is the function of this
- routine to construct the required matrices based on the angulation of the C-arm. The
- form of the matrices is the following (a = alpha & b = beta):
-
- p2a:
-
- -cos b -sin a sin b cos a sin b
- 0 cos a sin a
- sin b -sin a cos b cos a cos b
-
- a2p:
-
- -cos b 0 sin b
- -sin a sin b cos a -sin a cos b
- cos a sin b sin a cos a cos b
-
- PROGRAMMING NOTES:
-
- The elements of the matrices will be stored as sequential rows in the array.
-
- EXAMPLES:
-
- =============================================================================*/
-
- #include "clipinclude.h"
-
- ERRCODE mkmxa (alpha, beta, a2p, p2a)
-
- INT alpha; /* angle alpha for the AP C-arm */
- INT beta; /* angle beta for the AP C-arm */
- DOUBLE a2p[9]; /* array for 'AP to patient' transform matrix */
- DOUBLE p2a[9]; /* array for 'patient to AP' transform matrix */
-
- {
-
- DOUBLE sina, cosa; /* sine and cosine of alpha */
- DOUBLE sinb, cosb; /* sine and cosine of beta */
- ERRCODE erret = OK; /* error code */
-
- DOUBLE sin (); /* sine function */
- DOUBLE cos (); /* cosine function */
-
- /* get copies of sine's and cosine's */
-
- sina = sin((DOUBLE)alpha * Pi / 180);
- cosa = cos((DOUBLE)alpha * Pi / 180);
- sinb = sin((DOUBLE)beta * Pi / 180);
- cosb = cos((DOUBLE)beta * Pi / 180);
-
- /* construct matrices */
-
- p2a[0] = a2p[0] = -cosb;
- p2a[1] = a2p[3] = -sina * sinb;
- p2a[2] = a2p[6] = cosa * sinb;
- p2a[3] = a2p[1] = 0;
- p2a[4] = a2p[4] = cosa;
- p2a[5] = a2p[7] = sina;
- p2a[6] = a2p[2] = sinb;
- p2a[7] = a2p[5] = -sina * cosb;
- p2a[8] = a2p[8] = cosa * cosb;
-
- /* all done */
-
- return (erret);
-
- }